"use strict";(self.webpackChunkpromptmanager=self.webpackChunkpromptmanager||[]).push([[8903],{57697:function(e,n,t){t.d(n,{Z:function(){return B}});var r=t(45987),a=t(1413),i=t(29439),o=t(72397),u=t(61979),c=t(57012),l=t(86482),s=t(68096),d=t(47071),p=t(49900),f=t(90493),v=t(15021),m=t(20653),h=t(81918),g=t(42763),y=t(27888),x=t(72791),Z=t(80458),b=t(87309),w=t(56030),k=t(12705),j=t(89510),S=t(40406),C=t(80184);function _(e){var n=(0,w.sJ)(k.NM),t=(0,w.sJ)(k.c5),r=(0,x.useState)(!1),a=(0,i.Z)(r,2),o=a[0],u=a[1],c=n.concat(t.filter((function(e){return!n.some((function(n){return n.uuid===e.uuid}))})));return(0,C.jsxs)("div",{style:{width:"100%",display:"flex"},children:[(0,C.jsx)(Z.Z,{style:{width:"auto",textAlign:"left",flex:1,borderColor:"#000"},value:e.value,mode:"multiple",options:c.map((function(e){return{label:e.name,value:e.uuid}})),placeholder:"Select a datasource",status:"warning",onChange:function(n){return e.onChange(n)}}),(0,C.jsx)(b.ZP,{onClick:function(){return u(!0)},style:{backgroundColor:"#6287ac",color:"#fed766"},children:(0,C.jsx)(j.Z,{})}),(0,C.jsx)(S.P,{open:o,handleCancelCb:function(){return u(!1)},dataSourceAddedCb:function(n){return e.onChange(n.uuid)}})]})}var T=t(27480),D=t(48550);function M(e){var n,t,r,o,u,c=(0,x.useState)(e.value||(null===e||void 0===e||null===(n=e.schema)||void 0===n?void 0:n.default)||""),l=(0,i.Z)(c,2),s=l[0],d=l[1],p=(0,x.useState)(((null===e||void 0===e||null===(t=e.options)||void 0===t?void 0:t.enumOptions)||(null===e||void 0===e||null===(r=e.uiSchema)||void 0===r||null===(o=r["ui:options"])||void 0===o?void 0:o.enumOptions)||[]).map((function(e){return e.value}))),f=(0,i.Z)(p,2),v=f[0],m=f[1];return(0,x.useEffect)((function(){d(e.value)}),[e.value]),(0,C.jsx)(T.Z,{options:v,noOptionsText:"Enter to create a new option",getOptionLabel:function(e){return e},defaultValue:e.value||(null===e||void 0===e||null===(u=e.schema)||void 0===u?void 0:u.default)||v[0]||"",onInputChange:function(e,n){d(n)},renderInput:function(e){return(0,C.jsx)(D.Z,(0,a.Z)((0,a.Z)({},e),{},{label:"Select",variant:"standard",onKeyDown:function(e){"Enter"===e.key&&-1===v.findIndex((function(e){return e===s}))&&m((function(e){return e.concat(s)}))}}))},onChange:function(n,t){e.onChange(t)}})}var F=t(39585),O=["schema","uiSchema","formData","onChange","submitBtn","theme","validator","templates","widgets"],I=(0,u.Z)({spacing:2,typography:{fontSize:12},palette:{slider:{main:"#97afcf"}},components:{MuiTextField:{defaultProps:{variant:"outlined"},styleOverrides:{root:{"& .MuiOutlinedInput-root":{"& > fieldset":{border:"1px solid rgb(204, 204, 204)"}}}}},MuiInputBase:{defaultProps:{autoComplete:"off"},styleOverrides:{"& textarea":{border:"1px solid #ced4da"}}},MuiPaper:{styleOverrides:{root:{textAlign:"left","& .MuiTypography-root.MuiTypography-h5":{fontSize:"0.9rem",fontFamily:"Lato"},"& .MuiTypography-root.MuiTypography-subtitle2":{fontFamily:"Lato",color:"#666666",fontSize:"0.75rem"}}}},MuiSlider:{defaultProps:{size:"small",color:"slider"}},MuiSelect:{styleOverrides:{select:{textAlign:"left"}}},MuiFormControl:{styleOverrides:{root:{padding:"2px","& .MuiFormHelperText-root":{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block",textAlign:"left",margin:"2px"},"& .MuiFormHelperText-root.Mui-focused":{display:"block",overflow:"visible",textOverflow:"visible",whiteSpace:"normal"},"& .MuiFormControl-root:has(.MuiSlider-root) label":{fontSize:"0.75rem",textAlign:"start"}}}}}});function P(e){var n=e.id,t=e.children,r=e.classNames,a=e.style,o=e.disabled,u=e.displayLabel,c=e.hidden,p=e.label,f=e.onDropPropertyClick,v=e.onKeyChange,m=e.readonly,h=e.required,g=e.rawErrors,y=void 0===g?[]:g,Z=e.errors,b=e.help,w=e.rawDescription,k=e.schema,j=e.uiSchema,S=e.registry,_=(0,x.useState)(!1),T=(0,i.Z)(_,2),D=T[0],M=T[1],F=(0,l.LI)(j),O=(0,l.t4)("WrapIfAdditionalTemplate",S,F);return c?(0,C.jsx)("div",{style:{display:"none"},children:t}):(0,C.jsx)(O,{classNames:r,style:a,disabled:o,id:n,label:p,onDropPropertyClick:f,onKeyChange:v,readonly:m,required:h,schema:k,uiSchema:j,registry:S,children:(0,C.jsxs)(s.Z,{fullWidth:!0,error:!!y.length,required:h,onFocus:function(e){M(!0)},onBlur:function(e){M(!1)},children:[t,u&&w?(0,C.jsx)(d.Z,{id:n,focused:D,children:w}):null,Z,b]})})}function A(e){var n=e.options,t=e.registry,r=(0,l.t4)("BaseInputTemplate",t,n),i=5;return"string"!==typeof n.rows&&"number"!==typeof n.rows||(i=n.rows),(0,C.jsx)(r,(0,a.Z)((0,a.Z)({sx:{"& .MuiOutlinedInput-root":{"& > fieldset":{border:"1px solid rgb(204, 204, 204)"}}}},e),{},{multiline:!0,rows:i,variant:"outlined"}))}function L(e){return(0,C.jsx)(M,(0,a.Z)({},e))}function R(e){return(0,C.jsx)(F.Z,(0,a.Z)({},e))}function N(e){var n=e.chat_message;if(n.content)return(0,C.jsx)(p.Z,{primary:n.content});if(n.function_call){var t=n.function_call.name,r=JSON.parse(n.function_call.arguments),a=Object.keys(r).map((function(e){return"".concat(e,'="').concat(r[e],'"')})).join(",");return(0,C.jsx)("div",{children:(0,C.jsx)(p.Z,{primary:"Function",secondary:"".concat(t,"(").concat(a,")")})})}return null}var E=function(e){var n=e.value||[],t=0;return"string"===typeof n&&(n=[{content:n}]),(0,C.jsx)(f.Z,{className:"output-chat",style:{paddingTop:0},children:n.map((function(e){return(0,C.jsxs)(v.ZP,{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"10px",background:"rgb(255, 250, 236)",border:"1px solid rgb(235, 230, 236)",borderRadius:10},children:[(0,C.jsx)(m.Z,{children:(0,C.jsx)(h.Z,{color:"primary",label:e.role||"System"})}),(0,C.jsx)(N,{chat_message:e})]},t++)}))})},z=function(e){var n=e.value||[],t=0;return(0,C.jsx)(f.Z,{className:"output-text",style:{paddingTop:0},children:n.map((function(e){return(0,C.jsx)(v.ZP,{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"10px",background:"rgb(255, 250, 236)",border:"1px solid rgb(235, 230, 236)",borderRadius:10},children:(0,C.jsx)(p.Z,{primary:e})},t++)}))})},U=function(e){var n=0;return(0,C.jsx)(g.Z,{className:"output-image",cols:2,gap:8,children:e.value.map((function(e){return(0,C.jsx)(y.Z,{children:(0,C.jsx)("img",{src:"".concat(e),loading:"lazy",alt:""})},n++)}))})},V=function(e){return(0,C.jsx)("audio",{src:e.value,controls:!0})},B=function(e){var n=e.schema,t=e.uiSchema,i=e.formData,u=e.onChange,l=e.submitBtn,s=void 0===l?(0,C.jsx)("div",{}):l,d=e.theme,p=void 0===d?I:d,f=e.validator,v=e.templates,m=void 0===v?{}:v,h=e.widgets,g=void 0===h?{datasource:function(e){return(0,C.jsx)(_,(0,a.Z)({},e))},output_chat:E,output_text:z,output_image:U,output_audio:V}:h,y=(0,r.Z)(e,O);return(0,C.jsx)(c.Z,{theme:p,children:(0,C.jsx)(o.ZP,(0,a.Z)((0,a.Z)({},y),{},{schema:n,uiSchema:t,validator:f,formData:i,onChange:u,templates:(0,a.Z)((0,a.Z)({},m),{},{FieldTemplate:P}),widgets:(0,a.Z)((0,a.Z)({},{customselect:L,TextareaWidget:A,FileWidget:R,datasource:function(e){return(0,C.jsx)(_,(0,a.Z)({},e))}}),g),children:s}))})}},40406:function(e,n,t){t.d(n,{P:function(){return V}});var r=t(93433),a=t(29439),i=t(1413),o=t(72791),u=t(5289),c=t(65661),l=t(39157),s=t(53767),d=t(48550),p=t(2199),f=t(24518),v=t(97123),m=t(56030),h=t(12705),g=t(7077),y=t(26577),x=t(57697),Z=t(52803),b=t(81918),w=t(86482),k=t(39709),j=t(80184),S=["https://www.googleapis.com/auth/drive.readonly","https://www.googleapis.com/auth/drive.readonly.metadata"],C={marginTop:4};function _(e){return e.filter((function(e){return e})).map((function(e){var n=(0,w.OP)(e),t=n.blob;return{dataURL:e,name:n.name,size:t.size,type:t.type}}))}function T(e){return new Promise((function(n,t){if(window.gapi&&window.gapi.client.drive){var r={"application/vnd.google-apps.document":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.google-apps.spreadsheet":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.google-apps.presentation":"application/vnd.openxmlformats-officedocument.presentationml.presentation"},a=r.hasOwnProperty(e.mimeType),i=a?r[e.mimeType]:null;(a?window.gapi.client.drive.files.export({fileId:e.id,mimeType:i}):window.gapi.client.drive.files.get({fileId:e.id,alt:"media"})).then((function(t){var r=a?i:e.mimeType;n({dataURL:"data:".concat(r,";name=").concat(encodeURIComponent(e.name),";base64,")+window.btoa(t.body),name:e.name,size:t.body.length,type:e.mimeType})})).catch((function(e){console.error("Error loading the file:",e),t(e)}))}else t(new Error("Google Drive API is not ready"))}))}function D(e){var n=e.multiple,t=e.onChange,i=e.value,u=(0,o.useState)(null),c=(0,a.Z)(u,2),l=c[0],d=c[1],p=(0,o.useState)(null),v=(0,a.Z)(p,2),m=v[0],h=v[1],g=(0,o.useState)(!1),y=(0,a.Z)(g,2),x=y[0],Z=y[1],w=(0,o.useMemo)((function(){return Array.isArray(i)?_(i):_([i])}),[i]),D=(0,o.useState)(w),M=(0,a.Z)(D,2),F=M[0],O=M[1];(0,o.useEffect)((function(){if(window.gapi&&(window.gapi.load("picker"),window.gapi.load("client",(function(){window.gapi.client.setApiKey(""),window.gapi.client.load("drive","v3")}))),window.google&&!m){var e=window.google.accounts.oauth2.initTokenClient({client_id:"",scope:S.join(" "),callback:function(e){d(e.access_token)}});h(e)}}),[m]);var I=function(n){var r;n.action===window.google.picker.Action.PICKED&&(Z(!0),(r=n[window.google.picker.Response.DOCUMENTS],Promise.all(Array.from(r).map(T))).then((function(n){var r,a;O(n),Z(!1);var i=n.map((function(e){return e.dataURL}));null!==e&&void 0!==e&&null!==(r=e.schema)&&void 0!==r&&r.multiple||(null===e||void 0===e||null===(a=e.schema)||void 0===a?void 0:a.maxFiles)>1?t(i):t(i[0])})))},P=F.map((function(e,a){return(0,j.jsx)(b.Z,{label:e.name,onDelete:function(){return function(e){var a=(0,r.Z)(F);a.splice(e,1),O(a);var i=a.map((function(e){return e.dataURL}));t(n?i:i[0])}(a)}},a)}));return(0,j.jsxs)("div",{className:"container",children:[(0,j.jsx)("label",{style:{display:"flex"},children:e.label}),(0,j.jsx)("p",{}),(0,j.jsxs)(s.Z,{spacing:2,sx:{alignItems:"center",justifyContent:"center"},children:[l&&(0,j.jsx)(k.Z,{variant:"outlined",onClick:function(){return function(){if(l){var n,t=new window.google.picker.View(window.google.picker.ViewId.DOCS);null!==(n=e.schema)&&void 0!==n&&n.accepts&&t.setMimeTypes(Object.keys(e.schema.accepts).join(",")),(new window.google.picker.PickerBuilder).enableFeature(window.google.picker.Feature.NAV_HIDDEN).setDeveloperKey("").setAppId("").setOAuthToken(l).addView(t).setCallback(I).build().setVisible(!0)}}()},disabled:x,loading:x,children:"Choose File"}),l&&(0,j.jsx)(k.Z,{variant:"outlined",onClick:function(){l&&window.google.accounts.oauth2.revoke(l,(function(){d(null)}))},size:"small",disabled:x,loading:x,children:"SignOut"}),!l&&(0,j.jsx)(f.Z,{variant:"outlined",onClick:function(){return function(){if(!m){var e=window.google.accounts.oauth2.initTokenClient({client_id:"",scope:S,callback:function(e){d(e.access_token)}});h(e)}m&&m.requestAccessToken({prompt:""})}()},children:"Login to Google"}),P&&(0,j.jsx)("aside",{style:C,children:P})]})]})}var M=t(63466),F=t(57482),O=t(90493),I=t(15021),P=t(13400),A=t(49900),L=t(50686),R=t(27247);function N(e){var n=e.onChange,t=e.value,i=e.schema,u=(0,o.useState)(null),c=(0,a.Z)(u,2),l=c[0],p=c[1],f=(0,o.useState)(t?t.split(","):null),v=(0,a.Z)(f,2),m=v[0],h=v[1],y=(0,o.useState)(!1),x=(0,a.Z)(y,2),Z=x[0],b=x[1],w=(0,o.useState)(null),S=(0,a.Z)(w,2),C=S[0],_=S[1];(0,o.useEffect)((function(){if(null!==m||null!==l){var e=m?m.join(","):l;n(e),e.length>i.maxLength&&_("Too many URLs"),e.length<i.maxLength&&_(null)}}),[m,n,i.maxLength,l]);return(0,j.jsxs)("div",{className:"container",children:[(0,j.jsx)("label",{style:{display:"flex"},children:e.label}),(0,j.jsx)("p",{}),(0,j.jsxs)(s.Z,{spacing:2,sx:{},children:[(0,j.jsx)(d.Z,{disabled:Z,onChange:function(e){return p(e.target.value)},InputProps:{endAdornment:(0,j.jsx)(M.Z,{position:"end",children:(0,j.jsx)(k.Z,{onClick:function(){var e=l;h(null),b(!0),(0,g.o)().post("/api/datasources/url/extract_urls",{url:e}).then((function(n){h(n.data.urls||[e]),b(!1)})).catch((function(n){h([e]),b(!1)}))},isLoading:Z,disabled:Z,children:(0,j.jsx)(L.Z,{})})})}}),Z&&(0,j.jsx)(F.Z,{}),m&&m.length>0&&(0,j.jsxs)("div",{children:[(0,j.jsx)(O.Z,{dense:!0,sx:{maxHeight:"200px",overflowY:"scroll",border:C?"1px solid red":null},children:m.map((function(e,n){return(0,j.jsx)(I.ZP,{secondaryAction:(0,j.jsx)(P.Z,{onClick:function(){var e=(0,r.Z)(m);e.splice(n,1),h(e)},children:(0,j.jsx)(R.Z,{})}),children:(0,j.jsx)(A.Z,{primary:(0,j.jsx)("a",{href:e,target:"_blank",rel:"noreferrer",children:e})})},n)}))}),C&&(0,j.jsx)("p",{style:{color:"red"},children:C})]})]})]})}var E=t(58518);function z(e){return(0,j.jsx)(D,(0,i.Z)({},e))}function U(e){return(0,j.jsx)(N,(0,i.Z)({},e))}function V(e){var n=e.open,t=e.handleCancelCb,b=e.dataSourceAddedCb,w=e.modalTitle,k=void 0===w?"Add New Data Source":w,S=e.datasource,C=void 0===S?null:S,_=(0,m.sJ)(h.TF),T=(0,o.useState)(null!==C&&void 0!==C&&C.name?C.name:""),D=(0,a.Z)(T,2),M=D[0],F=D[1],O=(0,o.useState)(!1),I=(0,a.Z)(O,2),P=I[0],A=I[1],L=(0,m.FV)(h.NM),R=(0,a.Z)(L,2),N=R[0],V=R[1],B=(0,o.useState)(null!==C&&void 0!==C&&C.type?C.type:null===_||void 0===_?void 0:_[0]),H=(0,a.Z)(B,2),W=H[0],K=H[1],q=(0,o.useState)({}),G=(0,a.Z)(q,2),J=G[0],Y=G[1],Q=(0,Z.lD)();return(0,j.jsxs)(u.Z,{open:n,onClose:t,children:[(0,j.jsx)(c.Z,{children:k}),(0,j.jsx)(l.Z,{children:(0,j.jsxs)(s.Z,{spacing:2,children:[(0,j.jsx)(d.Z,{label:"Data Source Name",value:M,onChange:function(e){return F(e.target.value)},disabled:!!C,required:!0,defaultValue:(null===C||void 0===C?void 0:C.name)||"Untitled",size:"small",style:{width:"100%",marginTop:"6px"},error:P}),(0,j.jsx)("span",{children:"Data Source Type"}),(0,j.jsx)(p.Z,{variant:"outlined",size:"small",style:{display:"inline-block"},disabled:!!C,children:_.map((function(e){return(0,j.jsx)(f.Z,{variant:"outlined",onClick:function(n){K(e)},children:e.name},e.id)}))}),(0,j.jsx)(x.Z,{schema:(null===W||void 0===W?void 0:W.entry_config_schema)||{},validator:y.Z,uiSchema:(0,i.Z)((0,i.Z)({},(null===W||void 0===W?void 0:W.entry_config_ui_schema)||{}),{"ui:submitButtonOptions":{norender:!0},"ui:DescriptionFieldTemplate":function(){return null},"ui:TitleFieldTemplate":function(){return null}}),widgets:{gdrive:z,webpageurls:U},formData:J,onChange:function(e){var n=e.formData;Y(n)}})]})}),(0,j.jsxs)(v.Z,{children:[(0,j.jsx)(f.Z,{onClick:t,children:"Cancel"}),",",(0,j.jsx)(f.Z,{variant:"contained",onClick:function(){if(C)(0,g.o)().post("/api/datasources/".concat(C.uuid,"/add_entry"),{entry_data:J}).then((function(){Q()})),t(),(0,E.yv)("Processing Data, please refresh the page in a few minutes",{variant:"success"});else{if(""===M)return void A(!0);(0,g.o)().post("/api/datasources",{name:M,type:W.id,config:W.is_external_datasource?J:{}}).then((function(e){if(!W.is_external_datasource){var n=e.data;V([].concat((0,r.Z)(N),[n])),(0,g.o)().post("/api/datasources/".concat(n.uuid,"/add_entry"),{entry_data:J}).then((function(e){b(n)}))}})),t(),(0,E.yv)("Processing Data, please refresh the page in a few minutes",{variant:"success"})}},children:"Submit"})]})]})}},39585:function(e,n,t){t.d(n,{Z:function(){return Z}});var r=t(1413),a=t(93433),i=t(29439),o=t(72791),u=t(57831),c=t(86482),l=t(81918),s=t(82773),d=t(80184),p={flex:1,display:"flex",flexDirection:"column",alignItems:"center",padding:"20px",borderWidth:2,borderRadius:2,borderColor:"#eeeeee",borderStyle:"dashed",backgroundColor:"#fafafa",color:"#bdbdbd",outline:"none",transition:"border .24s ease-in-out"},f={borderColor:"#2196f3"},v={borderColor:"#00e676"},m={borderColor:"#ff1744"},h={marginTop:4};function g(e,n){return null===e?null:e.replace(";base64",";name=".concat(encodeURIComponent(n),";base64"))}function y(e){var n=e.name,t=e.size,r=e.type;return new Promise((function(a,i){var o=new window.FileReader;o.onerror=i,o.onload=function(e){var i;"string"===typeof(null===(i=e.target)||void 0===i?void 0:i.result)?a({dataURL:g(e.target.result,n),name:n,size:t,type:r}):a({dataURL:null,name:n,size:t,type:r})},o.readAsDataURL(e)}))}function x(e){return e.filter((function(e){return e})).map((function(e){var n=(0,c.OP)(e),t=n.blob;return{dataURL:e,name:n.name,size:t.size,type:t.type}}))}function Z(e){var n,t,c=e.multiple,g=e.onChange,Z=e.value,b=(0,o.useMemo)((function(){return Array.isArray(Z)?x(Z):x([Z])}),[Z]),w=(0,o.useState)(b),k=(0,i.Z)(w,2),j=k[0],S=k[1],C=j.map((function(e,n){return(0,d.jsx)(l.Z,{label:e.name,onDelete:function(){return _(n)}},n)})),_=function(e){var n=(0,a.Z)(j);n.splice(e,1),S(n);var t=n.map((function(e){return e.dataURL}));g(c?t:t[0])},T=(0,u.uI)({accept:(null===(n=e.schema)||void 0===n?void 0:n.accepts)||{},onDrop:function(n){var t;(t=n,Promise.all(Array.from(t).map(y))).then((function(n){var t,r;S(n);var a=n.map((function(e){return e.dataURL}));null!==e&&void 0!==e&&null!==(t=e.schema)&&void 0!==t&&t.multiple||(null===e||void 0===e||null===(r=e.schema)||void 0===r?void 0:r.maxFiles)>1?g(a):g(a[0])}))},multiple:e.schema.multiple||e.schema.maxFiles>1||!1,maxSize:e.schema.maxSize||2e7,maxFiles:e.schema.maxFiles||1}),D=T.getRootProps,M=T.getInputProps,F=T.isFocused,O=T.isDragAccept,I=T.isDragReject,P=(0,o.useMemo)((function(){return(0,r.Z)((0,r.Z)((0,r.Z)((0,r.Z)({},p),F?f:{}),O?v:{}),I?m:{})}),[F,O,I]);return(0,d.jsxs)("div",{className:"container",children:[(0,d.jsx)("label",{style:{display:"flex"},children:e.label}),(0,d.jsx)("p",{}),(0,d.jsxs)("div",(0,r.Z)((0,r.Z)({},D({style:P})),{},{children:[(0,d.jsx)("input",(0,r.Z)((0,r.Z)({},M()),{},{multiple:!1})),(0,d.jsxs)("p",{children:["Drag 'n' drop some files here, or click to select files. Maximum size of each file is ",(0,s.Z)((null===e||void 0===e||null===(t=e.schema)||void 0===t?void 0:t.maxSize)||2e7)]})]})),C&&(0,d.jsx)("aside",{style:h,children:C})]})}},12705:function(e,n,t){t.d(n,{$5:function(){return S},C_:function(){return N},DK:function(){return P},Dg:function(){return z},Hn:function(){return y},K4:function(){return k},MC:function(){return I},NM:function(){return M},TF:function(){return O},YL:function(){return g},c5:function(){return F},e7:function(){return V},eH:function(){return b},gZ:function(){return x},iB:function(){return w},jl:function(){return h},lo:function(){return L},nC:function(){return T},pQ:function(){return j},r1:function(){return v},rc:function(){return _},v:function(){return m},ye:function(){return A}});var r=t(4942),a=t(1413),i=t(74165),o=t(15861),u=t(56030),c=t(7077),l=(0,u.nZ)({key:"apiProvidersFetchSelector",get:function(){var e=(0,o.Z)((0,i.Z)().mark((function e(){var n;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/apiproviders");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),s=(0,u.nZ)({key:"apiBackendsFetchSelector",get:function(){var e=(0,o.Z)((0,i.Z)().mark((function e(){var n;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/apibackends");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),d=(0,u.nZ)({key:"endpointsFetchSelector",get:function(){var e=(0,o.Z)((0,i.Z)().mark((function e(){var n;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/endpoints");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),p=(0,u.nZ)({key:"dataSourcesFetchSelector",get:function(){var e=(0,o.Z)((0,i.Z)().mark((function e(){var n;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/datasources");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),f=(0,u.nZ)({key:"dataSourceTypesFetchSelector",get:function(){var e=(0,o.Z)((0,i.Z)().mark((function e(){var n;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/datasource_types");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),v=(0,u.cn)({key:"apiProviders",default:l}),m=(0,u.nZ)({key:"apiProviderDropdownList",get:function(){var e=(0,o.Z)((0,i.Z)().mark((function e(n){var t,r;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.get,e.next=3,t(v);case 3:return r=e.sent,e.abrupt("return",r.map((function(e){return{label:e.name,value:e.name}})));case 5:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}()}),h=(0,u.cn)({key:"apiProviderSelected",default:null}),g=(0,u.cn)({key:"apiBackends",default:s}),y=(0,u.nZ)({key:"apiBackendDropdownList",get:function(e){var n=e.get,t=n(g),r=n(V);return t.filter((function(e){return-1===((null===r||void 0===r?void 0:r.disabled_api_backends)||[]).indexOf(e.id)})).map((function(e){return{label:e.name,value:e.id,provider:e.api_provider.name}}))}}),x=(0,u.cn)({key:"apiBackendSelected",default:null}),Z=(0,u.cn)({key:"endpoints",default:d}),b=((0,u.nZ)({key:"endpointDropdownList",get:function(e){var n=(0,e.get)(Z);return n.filter((function(e){return 0===e.version&&!e.draft})).sort((function(e,n){return e.created_on<n.created_on?1:-1})).map((function(e){return{label:"".concat(e.api_backend.api_provider.name," \xbb ").concat(e.api_backend.name," \xbb ").concat(e.name),uuid:e.uuid,options:n.filter((function(n){return n.parent_uuid===e.uuid})).map((function(n){return{label:"".concat(n.version,": ").concat(n.description),value:"".concat(n.parent_uuid,":").concat(n.version),version:n.version,backend:e.api_backend.name,provider:e.api_backend.api_provider.name,is_live:n.is_live,uuid:n.uuid}}))}}))}}),(0,u.cn)({key:"endpointSelected",default:null})),w=(0,u.nZ)({key:"endpointTableData",get:function(e){for(var n=(0,e.get)(Z).filter((function(e){return!e.draft})).sort((function(e,n){return e.created_on<n.created_on?1:-1})),t=n.filter((function(e){return 0===e.version})).reduce((function(e,n){var t=(0,r.Z)({},n.uuid,(0,a.Z)((0,a.Z)({},n),{},{versions:[],key:n.uuid}));return(0,a.Z)((0,a.Z)({},e),t)}),{}),i=n.filter((function(e){return 0!==e.version})),o=0;o<i.length;o++)i[o].parent_uuid in t&&t[i[o].parent_uuid].versions.push((0,a.Z)((0,a.Z)({},i[o]),{},{key:i[o].uuid}));return Object.values(t)}}),k=((0,u.cn)({key:"endpointVersions",default:[]}),(0,u.cn)({key:"endpointConfigValue",default:{}})),j=(0,u.cn)({key:"promptValues",default:{}}),S=(0,u.cn)({key:"inputValue",default:{}}),C=((0,u.cn)({key:"saveEndpointModalVisible",default:!1}),(0,u.cn)({key:"saveEndpointVersionModalVisible",default:!1}),(0,u.cn)({key:"shareEndpointModalVisible",default:!1}),(0,u.cn)({key:"endpointShareCodeValue",default:null}),(0,u.nZ)({key:"profileFetchSelector",get:function(){var e=(0,o.Z)((0,i.Z)().mark((function e(){var n;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/profiles/me");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",null);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()})),_=(0,u.cn)({key:"profileValue",default:C}),T=(0,u.nZ)({key:"isLoggedIn",get:function(e){return null!==(0,e.get)(_)}}),D=(0,u.cn)({key:"promptHubState",default:[]}),M=((0,u.nZ)({key:"promptHubList",get:function(e){return(0,e.get)(D)}}),(0,u.cn)({key:"dataSourcesState",default:p})),F=(0,u.nZ)({key:"orgDataSourcesState",get:function(){var e=(0,o.Z)((0,i.Z)().mark((function e(n){var t,r;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.get,e.prev=1,t(z).IS_ORGANIZATION_MEMBER){e.next=5;break}return e.abrupt("return",[]);case 5:return e.next=7,(0,c.o)().get("/api/org/datasources");case 7:return r=e.sent,e.abrupt("return",r.data);case 11:return e.prev=11,e.t0=e.catch(1),e.abrupt("return",[]);case 14:case"end":return e.stop()}}),e,null,[[1,11]])})));return function(n){return e.apply(this,arguments)}}()}),O=(0,u.cn)({key:"dataSourceTypesState",default:f}),I=(0,u.cn)({key:"dataSourceEntriesState",default:[]}),P=(0,u.cn)({key:"orgDataSourceEntriesState",default:[]}),A=(0,u.nZ)({key:"dataSourceEntriesTableData",get:function(e){var n=e.get,t=n(I),r=n(z);t=t.map((function(e){return(0,a.Z)({isUserOwned:!0},e)}));var i=r.IS_ORGANIZATION_MEMBER?n(P):[];i=i.map((function(e){return(0,a.Z)({isUserOwned:!1},e)}));var o=n(M),u=(o=o.map((function(e){return(0,a.Z)({isUserOwned:!0},e)}))).map((function(e){return e.uuid})),c=r.IS_ORGANIZATION_MEMBER?n(F):[];c=(c=c.map((function(e){return(0,a.Z)({isUserOwned:!1},e)}))).filter((function(e){return!u.includes(e.uuid)}));for(var l=[],s={},d={},p=0;p<t.length;p++)t[p].datasource.uuid in s?s[t[p].datasource.uuid].push(t[p]):s[t[p].datasource.uuid]=[t[p]];for(var f=0;f<i.length;f++)i[f].datasource.uuid in d?d[i[f].datasource.uuid].push(i[f]):d[i[f].datasource.uuid]=[i[f]];for(var v=0;v<o.length;v++)l.push((0,a.Z)((0,a.Z)({},o[v]),{data_source_entries:s[o[v].uuid]||[]}));for(var m=0;m<c.length;m++)l.push((0,a.Z)((0,a.Z)({},c[m]),{data_source_entries:d[c[m].uuid]||[]}));return l}}),L=(0,u.cn)({key:"isMobileState",default:window.innerWidth<768}),R=((0,u.cn)({key:"appTemplateState",default:null}),(0,u.cn)({key:"appDebugState",default:{}}),(0,u.nZ)({key:"appsFetchSelector",get:function(){var e=(0,o.Z)((0,i.Z)().mark((function e(){var n;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/apps");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",[]);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()})),N=(0,u.cn)({key:"appsState",default:R}),E=(0,u.nZ)({key:"profileFlagsFetchSelector",get:function(){var e=(0,o.Z)((0,i.Z)().mark((function e(){var n;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/profiles/me/flags");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",{});case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),z=(0,u.cn)({key:"profileFlagsState",default:E}),U=(0,u.nZ)({key:"organizationFetchSelector",get:function(){var e=(0,o.Z)((0,i.Z)().mark((function e(){var n;return(0,i.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,c.o)().get("/api/org");case 3:return n=e.sent,e.abrupt("return",n.data);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",null);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}()}),V=(0,u.cn)({key:"organizationState",default:U})},7077:function(e,n,t){t.d(n,{o:function(){return i}});var r=t(11912),a=t(58518),i=function(){var e=r.Z.create({xsrfCookieName:"csrftoken",xsrfHeaderName:"X-CSRFToken"});return e.interceptors.response.use((function(e){return e}),(function(e){return window.location.pathname.startsWith("/s/")||window.location.pathname.startsWith("/hub")||window.location.pathname.startsWith("/app/")||401!==e.response.status&&403!==e.response.status||(window.location.href="/login"),(0,a.yv)("Error Occurred",{variant:"error"}),Promise.reject(e)})),e}},52803:function(e,n,t){t.d(n,{B6:function(){return o},lD:function(){return u}});var r=t(56030),a=t(12705),i=t(7077);function o(){var e=(0,r.Zl)(a.NM);return function(){(0,i.o)().get("/api/datasources").then((function(n){e(n.data)})).catch((function(e){})).then({})}}function u(){var e=(0,r.Zl)(a.MC);return function(){(0,i.o)().get("/api/datasource_entries").then((function(n){e(n.data)})).catch((function(e){})).then({})}}}}]);
//# sourceMappingURL=8903.78b8c156.chunk.js.map